package cn.com.czpb.client.module.live.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import cn.com.czpb.client.R;
import cn.com.czpb.client.app.ToolBarActivityWhite;
import cn.com.czpb.client.module.actives.HuodongFragment;
import cn.com.czpb.client.module.live.adapter.LivingPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class TxtAndPicActivity extends ToolBarActivityWhite {
    @BindView(R.id.txt_pic_content)
    TextView txt_pic_content;//直播简介
    @BindView(R.id.iv_more)
    ImageView iv_more;//显示更多
    private boolean IsShowMore;//是否显示更多

    @BindView(R.id.tab_txt_pic)
    TabLayout tabLayout;
    @BindView(R.id.viewpager_txt_pic)
    ViewPager viewpager_txt_pic;
    private LivingPagerAdapter adapter;
    private List<Fragment> list;
    @Override
    public int setMyContentView() {
        return R.layout.activity_txt_and_pic;
    }

    @OnClick(R.id.iv_more)
    public void GetMore(View view) {
        if (IsShowMore==false) {
            IsShowMore=true;
            txt_pic_content.setMaxLines(15);
        }else {
            IsShowMore=false;
            txt_pic_content.setMaxLines(2);
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }
    //初始化碎片
    private void init(){
        list = new ArrayList<>();
        adapter = new LivingPagerAdapter(getSupportFragmentManager(), list, activity);
        viewpager_txt_pic.setAdapter(adapter);
        tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.color_df3031));
        for (int i = 0; i < 2; i++) {
            HuodongFragment fragment=HuodongFragment.newInstance();
            list.add(fragment);
        }
        tabLayout.setupWithViewPager(viewpager_txt_pic);
        viewpager_txt_pic.setCurrentItem(2);
    }
}
